﻿using System;
using System.Windows;
using System.ComponentModel;
using System.Xml.Linq;


namespace Skyper.Model {
	/// <summary>
	/// Base Model
	/// </summary>
	public abstract class BaseModel : INotifyPropertyChanged,IModel {
		#region Protected
		/// <summary>
		/// Called when property changes.
		/// </summary>
		/// <param name="propertyName">Name of the property.</param>
		protected void OnPropertyChanged(String propertyName) {
			if (String.IsNullOrEmpty(propertyName)) {
				return;
			}
			if (this.PropertyChanged == null) {
				return;
			}
			this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}
		#endregion
		#region Public
		/// <summary>
		/// Suspends this model to XElement.
		/// </summary>
		/// <returns>XElement or Null if suspending is not possible.</returns>
		public virtual XElement Suspend() {
			return null;
		}
		/// <summary>
		/// Resumes this element, with specified node.
		/// </summary>
		/// <param name="node">The node.</param>
		/// <returns>True, if resuming proccess was success.</returns>
		public virtual bool Resume(XElement node) {
			return false;
		}
		#endregion
		#region Events
		/// <summary>
		/// Occurs when a property value changes.
		/// </summary>
		public event PropertyChangedEventHandler PropertyChanged;
		#endregion
	}
}
